


<?php
/*
 * TODO : add ajax add product and qty button in ajax into shopping cart back end 
*
 * 
*/
require_once('../Category/CATEGORY_session.php');
require_once('../Product/PRODUCT_session.php');


//$productRS = $products->findall();

$find_class = new SessionCATEGORY();
//$datas = $find_class->findall();
       
 $html ;   


        

        $query = "select DISTINCT CategoryID from Product";

        $result = mysql_query($query) or die(mysql_error());
        $arrayofcategoryid = array();
        
        while ($resultofCategoryID = mysql_fetch_array($result, MYSQL_NUM))
        {
            $arrayofcategoryid []=  $resultofCategoryID[0];
            
        }
        
        $arrayofProducts = array();
        for ($i = 0 ; $i <= count($arrayofcategoryid); $i++)
        {
            $query2 = "select ProductName, ProductID, CategoryID from Product where CategoryID = ". $i .";";
            $result2 = mysql_query($query2) or die(mysql_error());
              
            while ($resultofProductquery2 = mysql_fetch_array($result2, MYSQL_NUM))
                {
                    
                
                $arrayofProducts[]=$resultofProductquery2;
                
                
                   

                }
            
        }
        //print_r(count($arrayofProducts));
        //print_r ($arrayofcategoryid);
        //print_r ($arrayofProducts);
        
       
            
            for($row=0 ; $row < count($arrayofProducts);$row++)
            {
             if ($row == 0)
             {
                $buttons .= "<div id='tabs-".$arrayofProducts[$row][2]."'>\n";
             }

                for($k =0; $k <3 ; $k++)
                {


                    if ($k == 0 )   
                    {

                        $buttons.= "<button type='button' value = '".$arrayofProducts[$row][1]."'>" .$arrayofProducts[$row][0]. "</button>\n";


                    }


                }
              if($row==0)
              {
                $buttons .= "</div>\n";
              }
            
           
        }
        
        
        echo $buttons
        

?>
    
    
 